package io.renren.modules.admin.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.admin.entity.CourseDemoEntity;
import io.renren.modules.admin.service.CourseDemoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 课程动态演示
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-12-17 18:24:00
 */
@RestController
@RequestMapping("admin/coursedemo")
public class CourseDemoController {
    @Autowired
    private CourseDemoService courseDemoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("admin:coursedemo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = courseDemoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{courseDemoId}")
    @RequiresPermissions("admin:coursedemo:info")
    public R info(@PathVariable("courseDemoId") Long courseDemoId){
		CourseDemoEntity courseDemo = courseDemoService.getById(courseDemoId);

        return R.ok().put("courseDemo", courseDemo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("admin:coursedemo:save")
    public R save(@RequestBody CourseDemoEntity courseDemo){
		courseDemoService.save(courseDemo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("admin:coursedemo:update")
    public R update(@RequestBody CourseDemoEntity courseDemo){
		courseDemoService.updateById(courseDemo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("admin:coursedemo:delete")
    public R delete(@RequestBody Long[] courseDemoIds){
		courseDemoService.removeByIds(Arrays.asList(courseDemoIds));

        return R.ok();
    }

}
